package com.yiwyn.ood.lsp;

public class LSPBadDemo {

    public static void main(String[] args) {

        Calculator calculator = new Calculator();

        // 这里期望的加法
        int calc = calculator.calc(1, 2);
        System.out.println(calc); // 3
        Calculator sonCalc = new SonCalculator();
        int calc1 = sonCalc.calc(1, 2);
        System.out.println(calc1); // -1

    }

    // 计算类
    static class Calculator {
        // 默认加法
        public int calc(int a, int b) {
            return a + b;
        }
    }

    static class SonCalculator extends Calculator {

        @Override
        public int calc(int a, int b) {
            return a - b;
        }
    }


}
